package com.qdu.mapper;


import com.qdu.bean.temp_atempBean;
import com.qdu.bean.year_seasonBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class tempByYear_SeasonMapper extends Mapper<LongWritable, Text, year_seasonBean, temp_atempBean> {
    year_seasonBean ys=new year_seasonBean();
    temp_atempBean  ta=new temp_atempBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String  line=value.toString();
        String[]    data=line.split(",");
        String[]    time=data[0].split("/");


        double temp=Double.parseDouble(data[5]);
        double  atemp=Double.parseDouble(data[6]);

        ta.set(temp,atemp);

        String  year=time[0].toString();
        int  season=Integer.parseInt(data[1]);
        ys.set(year,season);

        context.write(ys,ta);
    }


}
